var status = 0;
var choice;
   var itemxh = new Array("2049700","5062002","5062000","5210001","5210000","5050100","5051001","5220040","5390004","5390006","5390010","5390019","5390020","5390022","5390031","5079001","5079002", "5079005",  "5390003", "5390005", "5390007", "5390008", "5390018", "5390030", "5390034");
   var itemxhcost = new Array("4800","3800","2500","4500","1000","1000","1500","500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500","1500");
function start() {
	status =  - 1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode ==  - 1)
		cm.dispose();
	else {
		if (status == 0 && mode == 0) {
			cm.dispose();
			return;
		} else if (status >= 1 && mode == 0) {
			cm.sendOk("真的不考虑购买一些东西么？好的,欢迎下次继续光临！");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			choices = "请选择您要购买的道具  #rPS：购买前请确认背包有足够的空间。\r\n#r#e #n#b";
			for (var i = 0; i < itemxh.length; i++) {
				choices += "\r\n#b#L" + i + "##v" + itemxh[i] + "##z" + itemxh[i] + "#　#d需要#r" + itemxhcost[i] + "#d点卷#k#l";
			}
			cm.sendSimpleS("" + choices, 2);
		} else if (status == 1) {
			cm.sendGetNumber("你选择的商品为#b#v" + itemxh[selection] + "#售价为：" + itemxhcost[selection] + "点卷/张\r\n请输入你购买的数量", 1, 1, cm.getPlayer().getCSPoints(2));
			choice = selection;
		} else if (status == 2) {
			fee = selection;
			money = fee * itemxhcost[choice];
			if (fee < 0) {
				cm.sendOk("不能输入0.或者你没有足够的点卷支付你要买的数量.!");
				cm.dispose();
			} else if (cm.getPlayer().getCSPoints(2) < money) {
				cm.sendOk("购买失败，你没有" + money + "抵用卷");
				cm.dispose();
			} else {
			    cm.gainNX(2, -money);
				cm.gainItem(itemxh[choice], fee);
				cm.worldSpouseMessage(0x0F, "[抵用商城] :玩家:" + "[" + cm.getChar().getName() + "]" + " " + "在" + cm.getServerName() + "在抵用商城购买了游戏道具.");
				cm.sendOk("只要坚持努力你也一定能变强！");
				cm.dispose();
			}
		}
	}
}
